package com.xsoft.demo12.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xsoft.demo12.R;
import com.xsoft.demo12.Utils;
import com.xsoft.demo12.activity.CollectionActivity;
import com.xsoft.demo12.db.UserDataBaseHelper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class MineFragment extends Fragment {
    private ImageView photo;
    private TextView name;
    private TextView collection;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_mine, container, false);
        photo = (ImageView) view.findViewById(R.id.photo);
        name = (TextView) view.findViewById(R.id.name);
        name.setText(new UserDataBaseHelper(getContext()).getName(Utils.getValue(getContext(), Utils.KEY_PHONE_NUM)));
        collection = (TextView) view.findViewById(R.id.collection);
        collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), CollectionActivity.class));
            }
        });
        return view;
    }
}
